<?php  
namespace app\api\model;

use think\Db;
use think\Exception;
use app\api\model\BaseModel;
use app\api\model\BannerItem;


class Banner extends BaseModel{

	// protected $table = '表名';
	protected $hidden = ['delete_time','update_time'];

	public function items(){
		// 模型,外键,当前模型的主键
		return $this->hasMany('BannerItem','banner_id','id');
	}

	public static function getBannerByID($id){
		// with('模型里的方法名'->可以是字符串,也可以是数组)  嵌套的关联关系用items.img
		$banner = self::with(['items','items.img'])->find($id);
		return $banner;
	}

}

?>